﻿using System.Collections;
using System.Text.Json.Serialization;

namespace BPM.Web.Shared.Data;

/// <summary>
/// 菜单树---授权、新增编辑时选择
/// </summary>
public class MenuTreeOutput : ITreeNode<MenuTreeOutput, long>
{
    /// <summary>
    /// 主键
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 父Id
    /// </summary>
    public long ParentId { get; set; }

    /// <summary>
    /// 名称
    /// </summary>
    public string? Title { get; set; }

    /// <summary>
    /// 值
    /// </summary>
    public string Value => IntValue.ToString();

    public long IntValue { get; set; }

    /// <summary>
    /// 排序，越小优先级越高
    /// </summary>
    public MenuWeight Weight { get; set; }

    /// <summary>
    /// 子节点
    /// </summary>
    public IEnumerable<MenuTreeOutput> Children { get; set; } = Enumerable.Empty<MenuTreeOutput>();

    public bool HasChildren => Children.Any();

    public long GetId() => Id;

    public long GetPid() => ParentId;
}
